<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增产品')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-manage-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">型号：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageId" id="manageId" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">品名：</label>
            <div class="col-sm-5">
                <input class="form-inline" type="text" name="manageName" id="manageName" required>
                <a class="btn btn-primary btn-rounded btn-sm" onclick="managePhotoView()"><i class="fa fa-search"></i>查看产品图库</a>
            </div>
        </div>
      <!--  <span th:if="${name}!='张三'">
            <div class="form-group">
            <label class="col-sm-3 control-label">展示：</label>
            <div class="col-sm-8">
                <img src="" width="50%" height="50%"/>
            </div>
            </div>
        </span>-->

        <div class="form-group">
            <label class="col-sm-3 control-label">类别：</label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" name="manageCategory" id="manageCategory">
                    <option value="">请选择</option>
                    <option value="1">家具</option>
                    <option value="2">饰品</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">系列： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="seriesId" name="seriesId" >
                    <option value="">请选择系列</option>
                    <option th:each="dict : ${series}" th:text="${dict.seriesName}" th:value="${dict.seriesId}"></option>
                 </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">风格： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="styleId" name="styleId" >
                    <option value="">请选择风格</option>
                    <option th:each="dict : ${style}" th:text="${dict.styleName}" th:value="${dict.styleId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
        <label class="col-sm-3 control-label">规格： </label>
        <div class="col-sm-8">
            <select class="form-control noselect2 selectpicker" id="speId" name="speId" >
                <option value="">请选择系列</option>
                <option th:each="dict : ${specification}" th:text="${dict.speName}" th:value="${dict.speId}"></option>
            </select>
        </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">材质：</label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" name="manageTexture" id="manageTexture">
                    <option value="">请选择材质</option>
                    <option value="1">面料</option>
                    <option value="2">五金件</option>
                    <option value="3">木饰面</option>
                    <option value="4">油漆</option>
                    <option value="5">其他</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">产地：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageOrigin" id="manageOrigin" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">单价：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="managePrice" id="managePrice" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">数量：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageNumber" id="manageNumber" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">金额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageMoney" id="manageMoney" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="manageDesc" name="manageDesc" class="form-control" >[[*{manageDesc}]]</textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">

    var prefix = ctx + "datum/manage";

    $("#form-role-add").validate({
        rules:{
            onkeyup: false,
            roleName:{
                remote: {
                    url: ctx + "system/role/checkRoleNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleName" : function() {
                            return $.common.trim($("#roleName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleKey:{
                remote: {
                    url: ctx + "system/role/checkRoleKeyUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleKey" : function() {
                            return $.common.trim($("#roleKey").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleSort:{
                digits:true
            },
        },
        messages: {
            "roleName": {
                remote: "角色名称已经存在"
            },
            "roleKey": {
                remote: "角色权限已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var manageId = $("input[name='manageId']").val();
        var manageName = $("input[name='manageName']").val();
        var manageCategory = $("select[name='manageCategory']").val();
        var seriesId = $("select[name='seriesId']").val();
        var styleId = $("select[name='styleId']").val();
        var speId = $("select[name='speId']").val();
        var manageTexture = $("select[name='manageTexture']").val();
        var manageOrigin = $("input[id='manageOrigin']").val();
        var managePrice = $("input[name='managePrice']").val();
        var manageNumber = $("input[name='manageNumber']").val();
        var manageMoney = $("input[name='manageMoney']").val();
        var manageDesc = $("textarea[name='manageDesc']").val();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "datum/manage/add",
            data : {
                "manageId": manageId,
                "manageName": manageName,
                "manageCategory": manageCategory,
                "seriesId": seriesId,
                "styleId": styleId,
                "speId": speId,
                "manageTexture": manageTexture,
                "manageOrigin": manageOrigin,
                "managePrice": managePrice,
                "manageNumber": manageNumber,
                "manageMoney": manageMoney,
                "manageDesc": manageDesc
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    /* 上传图片 */
    function managePhotoView() {
        var manageName = $("input[name='manageName']").val();
        var url = prefix + '/managePhotoView/' + manageName;
        $.modal.open("上传图片信息", url);
    }



</script>
</body>
</html>
